from django.db import models

# Create your models here.


from dataclasses import dataclass
from django.utils import timezone
from datetime import date


# 定义数据类
@dataclass
class TravelReimburseData:
    id:int
    name: str
    userid: int
    create_name: str = "系统创建"
    edit_name: str = "系统修改"
    create_time: date = None  # 自动生成
    edit_time: date= None    # 自动生成

    def __post_init__(self):
        """自动生成时间戳"""
        now =  timezone.localtime(timezone.now()).date()
        if self.create_time is None:
            self.create_time = now
        if self.edit_time is None:
            self.edit_time = now